package Algorithms;

public class Fibonacci {
    public int getFibonacci(int n){
        if (n <  1)return 0;
        if (n == 1 || n == 2)return 1;
        int a1 = 1, a2 = 1;
        int sum = 0;
        for (int i = 3; i <= n; i++) {
            sum = a1+a2;
            a1 = a2;
            a2 = sum;
        }
        return sum;
    }

    public static void main(String[] args) {
        System.out.println(new Fibonacci().getFibonacci(4));
    }
}
